package com.heima.user.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.model.user.pojos.ApUserRealname;
import com.heima.user.service.ApUserRealnameService;
import com.heima.user.service.ApUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * author Link
 *
 * @version 1.0
 * @date 2025/4/17  13:38
 */
@RestController
@RequestMapping("/api/v1/auth")
@Slf4j
public class ApUserRealnameController {

    @Autowired
    private ApUserRealnameService apUserRealnameService;

    /**
     * 用户审核查询列表
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody AuthDto dto){
        log.info("用户审核查询列表:{}",dto);
        return apUserRealnameService.listRelname(dto);
    }

    /**
     * 用户身份审核通过
     * @param dto
     * @return
     */
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto){
        log.info("用户身份审核通过:{}",dto);
        return apUserRealnameService.updateStatus(dto, ApUserRealname.Status.PASS.getCode());
    }

    /**
     * 用户身份审核失败
     * @param dto
     * @return
     */
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto){
        log.info("用户身份审核失败:{}",dto);
        return apUserRealnameService.updateStatus(dto,ApUserRealname.Status.FAILED.getCode());
    }

}
